package com.ikas.ai.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;


/**
 * json工具
 * @author dbh
 */
public class JsonUtil {

    /**
     * 判断字符串是否是json对象
     * @param string
     * @return
     */
    public static boolean isJsonObject(String string) {
        try {
            Object object = JSON.parse(string);
            if(object instanceof JSONObject) {
                return true;
            }else{
                return false;
            }
        } catch (Exception e) {
            return false;
        }
    }

    /**
     * 判断字符串是否是json集合对象
     * @param string
     * @return
     */
    public static boolean isJsonArray(String string) {
        try {
            Object object = JSON.parse(string);
            if(object instanceof JSONArray) {
                return true;
            }else{
                return false;
            }
        } catch (Exception e) {
            return false;
        }
    }
}
